package com.budwk.app.sqfwV2.enums.lanHuaDu;

import com.budwk.app.sqfwDoc.codeGenerator.pdfGenerate.BaseTemplatePdfGenerator;
import com.budwk.app.sqfwV2.generator.lanhuadu.pdf.lhdOrderLetterDocGenerator;
import com.budwk.app.sqfwV2.generator.lanhuadu.pdf.lhdRecReDocGenerator;
import com.budwk.app.sqfwV2.generator.lanhuadu.pdf.lhdSafetyHazardDocGenerator;
import com.budwk.app.sqfwV2.generator.lanhuadu.pdf.lhdWorkReportDocGenerator;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

/**
 * 兰花都街道
 */
@Getter
public enum LanHuaDuFileServiceEnum {

    B("lhd_safety_hazard_report", new lhdSafetyHazardDocGenerator(),"sqfwV2/daYingLu/lanhuadu/lhdSafetHazardReport.docx",
            "安全隐患报告", 102, "202424d070e47e3740c591638fb0af219d31", "/preview/safety/dayinglu/lhd_safety_hazard_report.png", "全部数据|合集"),
    C("lhd_work_report", new lhdWorkReportDocGenerator(),"sqfwV2/daYingLu/lanhuadu/lhdWorkReport.docx",
            "工作汇报", 103, "202492ea819e51e2477bb317e89d448e3998", "/preview/safety/dayinglu/lhd_work_report.png", "全部数据"),
    D("lhd_order_rectification_letter", new lhdOrderLetterDocGenerator(),"sqfwV2/daYingLu/lanhuadu/lhdOrderRectificationLetter.docx",
            "责令限期整改指令书", 104, "2024004c40f5bc2e46518cd507b2958a495c", "/preview/safety/dayinglu/lhd_order_rectification_letter.png", "全部数据|合集|限期整改"),
    E("lhd_rectification_review_opinion", new lhdRecReDocGenerator(),"sqfwV2/daYingLu/lanhuadu/lhdRectificationReviewOpinion.docx",
            "整改复查意见书", 105, "2024bd4765c099dd438bb9a21140a584d788", "/preview/safety/dayinglu/lhd_rectification_review_opinion.png", "全部数据|合集|隐患整改");

    private final String code;

    private final BaseTemplatePdfGenerator service;

    private final String filePath;

    private final String fileName;

    private final int location;

    private final String templateId; // 模板id

    private final String previewImage;

    private final String label;

    LanHuaDuFileServiceEnum(String code, BaseTemplatePdfGenerator service, String filePath, String fileName, int location, String templateId, String previewImage, String label) {
        this.code = code;
        this.service = service;
        this.filePath = filePath;
        this.fileName = fileName;
        this.location = location;
        this.templateId = templateId;
        this.previewImage = previewImage;
        this.label = label;
    }

    public static List<LanHuaDuFileServiceEnum> getAllPdf() {
        return List.of(B, C, D, E);
    }

    /**
     * @param code
     * @return
     */
    public static BaseTemplatePdfGenerator getService(String code) {
        Optional<LanHuaDuFileServiceEnum> optional = Arrays.stream(values()).filter(e -> e.getCode().equals(code)).findFirst();
        return optional.map(LanHuaDuFileServiceEnum::getService).orElse(null);
    }

    /**
     * @param code
     * @return
     */
    public static LanHuaDuFileServiceEnum getByCode(String code) {
        Optional<LanHuaDuFileServiceEnum> optional = Arrays.stream(values()).filter(e -> e.getCode().equals(code)).findFirst();
        return optional.orElse(null);
    }
}
